package org.huangrui.spark.java.core.rdd.instance;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

/**
 * @Author hr
 * @Create 2024-10-16 7:27
 */
public class Spark02_RDD_Memory {
    public static void main(String[] args) {
        SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("sparkCore");
        JavaSparkContext jsc = new JavaSparkContext(conf);
        // TODO 构建RDD数据处理模型
        // 利用环境对象对接内存数据源构建RDD对象
        List<String> list = Arrays.asList("zhangsan", "lisi", "wangwu");
        // TODO parallelize(并行)方法可以传递参数构建RDD对象
        JavaRDD<String> rdd = jsc.parallelize(list);
        List<String> collect = rdd.collect();
        collect.forEach(System.out::println);

        jsc.close();
    }
}
